package com.crape.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.crape.account.bo.IAccountBO;
import com.crape.common.constants.MessageCode;
import com.crape.common.enums.DarrenstatusType;
import com.crape.common.enums.UserType;
import com.crape.common.model.Account;

@Controller
public class AdminAccountController {

    private IAccountBO accountBOImpl;

    @Autowired
    public void setAccountBOImpl(IAccountBO accountBOImpl) {
        this.accountBOImpl = accountBOImpl;
    }

    @RequestMapping("/admin/account/listAccount.jsp")
    public String listAccount(ModelMap modelMap, Account account) {
        List<Account> accountList = accountBOImpl.findAccounts(account);
        modelMap.put("account", account);
        modelMap.put("accountList", accountList);
        return "/admin/account/listAccount.html";
    }

    @RequestMapping("/admin/account/listDarrenApply.jsp")
    public String listDarrenApply(ModelMap modelMap, Account account) {
        if (account == null) {
            modelMap.put(MessageCode.key, MessageCode.PARAMS_IS_NULL);
            return "/admin/account/darrenAudit.html";
        }
        account.setUsertype(UserType.user.getCode());
        account.setDarrenstatus(DarrenstatusType.toApply.getCode());
        List<Account> accountList = accountBOImpl.listAccounts(account);
        modelMap.put("account", account);
        modelMap.put("accountList", accountList);
        return "/admin/account/darrenAudit.html";
    }

}
